/**  
 * All rights Reserved, Designed By Android_Robot   
 * @Title:  ZoneHuoDongUtil.java   
 * @Package com.swift.maintenance.utils   
 * @Description:    TODO(用一句话描述该文件做什么)   
 * @author: HYM     
 * @date:   2017-7-25 上午11:35:49   
 * @version V1.0     
 */
package com.swift.maintenance.utils;

import android.content.Context;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.jiyi.common.StringInterface;
import com.jiyi.common.VolleyRequest;
import com.jiyi.inteface.DetailHuoDongInterface;
import com.jiyi.inteface.WebApi;
import com.swift.base.ApplicationBase;
import com.swift.maintenance.R;
import com.swift.maintenance.base.AppConfig;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: ZoneHuoDongUtil
 * @Description:TODO(这里用一句话描述这个类的作用)
 * @author: HYM
 * @date: 2017-7-25 上午11:35:49
 * 
 */
public class ZoneHuoDongUtil {

	// 1.等待报名,2.用户可参与，3.等待开始，4.进行中，5.活动结束，6.活动取消
	public static void setStatus(TextView tvState, int status) {
		switch (status) {
		case 1:
			tvState.setText("等待报名");
			tvState.setBackgroundResource(R.drawable.round_huodong_state_small_blue);
			break;
		case 2:
			tvState.setText("申请参与");
			tvState.setBackgroundResource(R.drawable.round_huodong_state_small_blue);
			break;
		case 3:
			tvState.setText("待开始");
			tvState.setBackgroundResource(R.drawable.round_huodong_state_small_blue);
			break;
		case 4:
			tvState.setText("进行中");
			tvState.setBackgroundResource(R.drawable.round_huodong_state);
			break;
		case 5:
			tvState.setText("活动结束");
			tvState.setBackgroundResource(R.drawable.round_huodong_state_gray);
			break;
		case 6:
			tvState.setText("活动取消");
			tvState.setBackgroundResource(R.drawable.round_huodong_state_gray);
			break;
		default:
			break;
		}

		// return tvState;
	}

	public static void getData(String huoDongId, Context context,
			final DetailHuoDongInterface detailHuoDongInterface) {
		String account = ApplicationBase.LocalData.getString("input.user", "");
		String password = ApplicationBase.LocalData.getString("password", "");

		Map<String, String> params = new HashMap<String, String>();
		params.put(AppConfig.ACCESS_TOKEN, UserInfoUtil.getCurrentUserAccessToken());
		params.put("id", huoDongId);

		VolleyRequest.StringRequestPost(context, WebApi.ZONE_HUODONG_DETAIL,
				"", params, new StringInterface(context) {

					@Override
					public void stringSuccess(String result) {
						detailHuoDongInterface.OnSuccessListener(result);
					}

					@Override
					public void stringError(VolleyError error) {
						ToastUtil.getInstances().showMsg(R.string.err_http_response);
					}
				});
	}

}
